package com.cos.controller;

import com.cos.entity.GoodsTypes;
import com.cos.service.GoodsTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/goodsType")
public class GoodsTypeController {

    @Autowired
    private GoodsTypeService goodsTypeService;

    @RequestMapping("/getList")
    @ResponseBody
    public List<GoodsTypes> getList(){
        return goodsTypeService.list();
    }

    @RequestMapping("/addGoodsType")
    @ResponseBody
    public boolean addGoodsType(@RequestBody GoodsTypes goodsTypes){
        return goodsTypeService.save(goodsTypes);
    }

    @RequestMapping("/updateGoodsType")
    @ResponseBody
    public boolean updateGoodsType(@RequestBody GoodsTypes goodsTypes){
       return   goodsTypeService.updateById(goodsTypes);
    }
    @RequestMapping("/deleteById")
    @ResponseBody
    public boolean deleteById(@RequestBody Integer id){
        return goodsTypeService.removeById(id);
    }
}
